<?php
  
  /**
   * strips out bad characters and make text safe.
   * @param string $string
   * @return string
   */
  function safe_output($string)
  {
    return htmlentities(strip_tags($string));
  }


	/**
	 * formats our date and makes it pretty
	 * @param string $mysql_timestamp
	 * @return string;
	 */
  function format_date($mysql_timestamp)
  {
    $unix_time = strtotime($mysql_timestamp);
		
		return date('F j Y g:i a', $unix_time);
  }


	function tag_cloud($tags)
	{
	  	$classes = 5;
		$max = 0;
		
		
		foreach($tags as $tag)
		{
		  if($tag['count'] > $max) { $max = $tag['count']; } 	
		}
		
		$divisor = ( $max / $classes ) + 1;
		
		foreach($tags as $tag)
		{
		  $tags_array[] = array('name' => $tag['name'], 
				                   'count' => $tag['count'], 
				                   'class' => ceil($tag['count'] / $divisor) );
		}
		
		return $tags_array;
		
	}
	
	
	function default_foto($id)
	{
		if($id) { return $id; }
		return 'default';
	}



?>
